#include "Axis.h"
#include "WAppManager.h"
#include "WSceneRenderer.h"

#include "anttweakbar\AntTweakBar.h"

#include <sstream>

Axis::Axis(std::vector<glm::vec3> pts, std::vector<glm::vec4> colors, std::string material)
	: WLine(pts, colors, material)
{
	enabledPtr = std::shared_ptr<bool>(&this->enabled);
	enabledParam = std::shared_ptr<Parameter<bool>>(new Parameter<bool>(IParameter::Bool, enabledPtr));

	//register pointer to global param map
	std::string key = std::string("Axis.Enabled");
	WAppManager::Instance()->RegisterParameter(key, enabledParam);

	std::stringstream ss;
	ss << " label='" << key << "' key=space help='Toggle auto-rotate mode.' ";
	std::string twString = ss.str();
	

	//register pointer to gui
	std::shared_ptr<WSceneRenderer> renderer = std::dynamic_pointer_cast<WSceneRenderer>(WRenderer::renderer);
	std::shared_ptr<Parameter<bool>> ptr = std::static_pointer_cast<Parameter<bool>>(enabledParam);
	TwAddVarRW(renderer->antTweakBar.get(), key.c_str(), TW_TYPE_BOOL32, ptr->GetPtr().get(), 
               twString.c_str());
}